package com;

import com.god530.androidutils.R;

import android.app.Activity;
import android.os.Bundle;
import android.os.SystemClock;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout.LayoutParams;
import android.widget.LinearLayout;

public class MainActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);
		LinearLayout androidutils_llayout = (LinearLayout) this.findViewById(R.id.androidutils_llayout);
		initFunctions(androidutils_llayout);
		//initSetTimeButtonClick();

		//		ContentValues values = new ContentValues();
		//		values.put("key", new byte[]{}); // 添加byte数组数据
		//		byte[] asByteArray = values.getAsByteArray("key");

		//		Bundle bundle = new Bundle();
		//		bundle.putByteArray("key", new byte[]{});
		//		byte[] byteArray = bundle.getByteArray("key");

		//UtilsService.startUtilsService(this);
	}

	public void initFunctions(ViewGroup viewGroup) {
		startRoundButton(viewGroup);
		startCrazyShaowButton(viewGroup);
		start21FragmentTransitionButton(viewGroup);
		startMaterialDesignButton(viewGroup);
		startRectCircleProgressButton(viewGroup);
	}

	public void startRectCircleProgressButton(ViewGroup viewGroup) {
		Button btn = new Button(this);
		btn.setText("带有进度条的按钮");
		btn.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
		btn.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				com.clownqiang.sample.MainActivity.startRectCircleProgressActivity(MainActivity.this);
			}
		});
		viewGroup.addView(btn);
	}
	
	//com.gc.materialdesign.ui
	public void startMaterialDesignButton(ViewGroup viewGroup) {
		Button btn = new Button(this);
		btn.setText("一些材料设计的库，超好用");
		btn.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
		btn.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				com.gc.materialdesign.ui.MainActivity.startMaterialDesignLibrarayActivity(MainActivity.this);
			}
		});
		viewGroup.addView(btn);
	}

	/**
	 * 开启21种Fragment切换的效果
	 * @param viewGroup
	 */
	public void start21FragmentTransitionButton(ViewGroup viewGroup) {
		Button btn = new Button(this);
		btn.setText("21中Fragment切换的动画效果");
		btn.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
		btn.setOnClickListener(new View.OnClickListener() {
			@Override
			public void onClick(View v) {
				com.desarrollodroide.fragmenttrasitionextendedexample.MainActivity.startFragmentTrasitionActivity(MainActivity.this);
			}
		});
		viewGroup.addView(btn);
	}

	private void startCrazyShaowButton(ViewGroup viewGroup) {
		Button btn = new Button(this);
		btn.setText("CrazyShadow");
		btn.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
		btn.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				com.hitomi.crazyshadow.MainActivity.startCrazyShadowActivity(MainActivity.this);
			}
		});
		viewGroup.addView(btn);
	}

	/**
	 * 开启RoundButton
	 */
	private void startRoundButton(ViewGroup viewGroup) {
		Button btn = new Button(this);
		btn.setText("RoundButton");
		btn.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
		btn.setOnClickListener(new View.OnClickListener() {

			@Override
			public void onClick(View v) {
				com.github.czy1121.roundbutton.demo.MainActivity.startRoundButtonActivity(MainActivity.this);
			}
		});
		viewGroup.addView(btn);
	}

	/**
	 * 需要在/system目录下， 需要权限
	 */
	private void initSetTimeButtonClick(){

		SystemClock.setCurrentTimeMillis(1471596208091L); 
		//		try {
		//			SystemDateTime.setTimeMillis(1471595296563L);
		//		} catch (IOException e) {
		//			e.printStackTrace();
		//		} catch (InterruptedException e) {
		//			e.printStackTrace();
		//		}
		//		this.findViewById(R.id.main_setsystemtimer).setOnClickListener(new OnClickListener(){
		//
		//			@Override
		//			public void onClick(View v) {
		//				((AlarmManager)getSystemService(Context.ALARM_SERVICE)).setTime(1471590764027L);
		//			}
		//			
		//		});
	}



	@Override
	protected void onResume() {
		super.onResume();
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// Handle action bar item clicks here. The action bar will
		// automatically handle clicks on the Home/Up button, so long
		// as you specify a parent activity in AndroidManifest.xml.
		int id = item.getItemId();
		if (id == R.id.action_settings) {
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
}
